<template>
<div class="newUser">
	<div class="topTit">
		<h1>设置新密码</h1>
		<!-- <p>请为 <span>{{ phoneHide }}</span> 账号设置密码</p> -->
	</div>
	<div class="con">
		<label>
			<input type="password" placeholder="新密码" v-model="newPass">
		</label>
		<label>
			<input type="password" placeholder="确认新密码" v-model="confirmPass">
		</label>
		<input type="button" :value="btnVal" :disabled='!disabled' @click='registered' :class='{active: disabled}' class="submit">
	</div>
</div>
</template>

<script>
// import { registered } from '../../../config/getData.js'

export default {
	data(){
		return {
			newPass:'',
			confirmPass:'',
			btnVal: '确认'
		}
	},
	props:{
		'phoneStr': {
			type: String,
			default: ''
		},
		'codeStr': {
			type: String,
			default:''
		}
	},
	computed: {
		disabled(){
			return !!this.newPass && !!this.confirmPass
		},
		phoneHide(){
			return this.phoneStr.substr(0,3) + '****' + this.phoneStr.substr(7,4)
		}
	},
	mounted () {
		if(this.$route.params.phone !== undefined){
			this.btnVal = '确认修改'
		}
	},
	methods: {
		registered(){
			var that = this;
			if(this.newPass !== this.confirmPass) {
				this.$vux.toast.show({
					text: '两次密码不一致！',
					width:'auto',
				})
				return false;
			}

			this.$vux.toast.show({
				text: '更改登录密码成功！,请重新登录',
				type:'success',
			})

			this.$router.push('/login')
			// registered(this.phoneStr,this.newPass,this.codeStr).then( res => {
			// 	if(res.code == 2) that.$router.push('/user/login')
			// })
		}
	}
}
</script>


<style lang="scss" scoped>
@import '../../assets/css/login.scss';
.newUser{
	.topTit{margin-bottom: 76px;}
	.con{
		label + label{margin-top:20px;}
		.submit{margin-top:40px;}
	}
}
</style>



